package org.hxyjs.mq.fair;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import org.hxyjs.mq.ConnectionUtils;

public class SendL {

    private static final String QUEUE_NAME = "java015_queue";


    public static void main(String args[]) throws Exception {
        //获取连接
        Connection connection = ConnectionUtils.getConnection();

        //获取channel
        Channel channel = connection.createChannel();

        //声明队列
        channel.queueDeclare(QUEUE_NAME, false, false, false, null);

        for (int i = 0; i < 50; i++) {
            String message = "hello world " + i;
            System.out.println("[WQ] SendMsg " + message);
            channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
            Thread.sleep(i * 20);
        }

        channel.close();
        connection.close();
    }
}